package com.ruoyi.web.controller.water;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.control.water.domain.Jingxia;
import com.ruoyi.control.water.service.IJingxiaService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 水文监测Controller
 *
 * @author ruoyi
 * @date 2024-10-30
 */
@RestController
@RequestMapping("/water/jingxia")
public class JingxiaController extends BaseController
{
    @Autowired
    private IJingxiaService jingxiaService;

    /**
     * 查询水文监测列表
     */
    @PreAuthorize("@ss.hasPermi('water:jingxia:list')")
    @GetMapping("/list")
    public TableDataInfo list(Jingxia jingxia)
    {
        startPage();
        List<Jingxia> list = jingxiaService.selectJingxiaList(jingxia);
        return getDataTable(list);
    }

    /**
     * 导出水文监测列表
     */
    @PreAuthorize("@ss.hasPermi('water:jingxia:export')")
    @Log(title = "水文监测", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Jingxia jingxia)
    {
        List<Jingxia> list = jingxiaService.selectJingxiaList(jingxia);
        ExcelUtil<Jingxia> util = new ExcelUtil<Jingxia>(Jingxia.class);
        util.exportExcel(response, list, "水文监测数据");
    }

    /**
     * 获取水文监测详细信息
     */
    @PreAuthorize("@ss.hasPermi('water:jingxia:query')")
    @GetMapping(value = "/{AutoID}")
    public AjaxResult getInfo(@PathVariable("AutoID") Long AutoID)
    {
        return success(jingxiaService.selectJingxiaByAutoID(AutoID));
    }

    /**
     * 新增水文监测
     */
    @PreAuthorize("@ss.hasPermi('water:jingxia:add')")
    @Log(title = "水文监测", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Jingxia jingxia)
    {
        return toAjax(jingxiaService.insertJingxia(jingxia));
    }

    /**
     * 修改水文监测
     */
    @PreAuthorize("@ss.hasPermi('water:jingxia:edit')")
    @Log(title = "水文监测", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Jingxia jingxia)
    {
        return toAjax(jingxiaService.updateJingxia(jingxia));
    }

    /**
     * 删除水文监测
     */
    @PreAuthorize("@ss.hasPermi('water:jingxia:remove')")
    @Log(title = "水文监测", businessType = BusinessType.DELETE)
	@DeleteMapping("/{AutoIDs}")
    public AjaxResult remove(@PathVariable Long[] AutoIDs)
    {
        return toAjax(jingxiaService.deleteJingxiaByAutoIDs(AutoIDs));
    }
}
